const fs = require('fs');
module.exports={
	setData:function(data){
		fs.writeFile('./chapters.txt',JSON.stringify(data),'utf8',function(err) {
		    if(err) throw err;
		});
	},
	getData:function(){
		return new Promise((resolve,reject)=>{
			fs.readFile('./chapters.txt',function(err,data){
				 let result=[]
				 if(err){
					 resolve(result);
				 }else{
					 result=data.toString()
					 result=JSON.parse(data)
					 resolve(result)
				 }
			});
		})
	}
}
